package com.fintecher.service.serviceImpl;

import com.fintecher.dao.IRoleDao;
import com.fintecher.dao.IUserDao;
import com.fintecher.pojo.Role;
import com.fintecher.pojo.User;
import com.fintecher.service.IUserService;
import com.fintecher.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service("userService")
public class UserServiceImpl implements IUserService {
	@Autowired
	private IUserDao userDao;
	private IRoleDao roleDao;
	public List<User> findAll() {
		return null;
	}

	public User find(String companyUphone,String companyName) {

		return userDao.find(companyUphone,companyName);
	}
	public User find1(String companyUphone,String companyName) {

		return userDao.find1(companyUphone,companyName);
	}

	@Override
	public Integer getCount(Integer id) {
		return userDao.getCount(id);
	}

	public User Longin(User user) {
		User users=userDao.Longin(user);
		if (users!=null){
			return users;
		}
		return users;
	}

	public Integer adduser(User user) {

		return userDao.adduser(user);
	}

	public boolean update(User user) {
		return userDao.update(user);
	}

	public User findUserByUphone(String companyUphone) {
		User user=userDao.findUserByUphone(companyUphone);
		return user ;
	}


/*	public List<User> find1() {
		return null;
	}*/

	public List<User> finds(String  companyUphone) {
		return userDao.finds(companyUphone);
	}

	/*public List<User> find1() {
		List<User> user=userDao.find1();
		return user;
	}*/

	public User Longin1(User user) {
		return userDao.Longin1(user);
	}

	public void addUserMin(User user) {
	userDao.addUserMin( user );
	}

	/**
	 * 查询本账号下所有的用户组
	 * @param user
	 * @return
	 */

	public List<Role> selUserGroupRole(User user){
		List<Role> roleList =  userDao.selUserGroupRole(user);
		return roleList;
	}



	public User getUserByCompanyName(String companyName) {
		return null;
	}
	/**
	 * @在审核用户时候
	 * 修改用户状态
	 * @param user
	 * @return
	 */

	public boolean updateUserState(User user) {
		boolean updateUser = userDao.updateUserState(user);
		return true;
	}


	/**
	 * 删除用户，进行逻辑删除
	 * @param id
	 * @return
	 */
	public Integer delUser(Integer id){

		if(id != null){
			Integer flag = userDao.delUser(id);
			if(flag>0){
				return flag;
			}
		}
		return null;
	}

	/**
	 * 修改用户禁用启用按钮
	 * @param user
	 * @return
	 */
	public  boolean updateUserIsdisables(User user){
		boolean flag = userDao.updateUserIsdisables(user);
		if(flag){
			return true;
		}

		return false;
	}

}
